$(function() {
        bindOrderProcessAHref();


        $(".J_subOrder").click(function() {
                if ($(this).text() == "收起子订单") {
                        var $parent = $(this).parents("tr");
                        $parent.removeClass("td_line");
                        $parent.next(".hide").hide();
                        $(this).removeClass("cur").text("展开子订单");
                } else {
                        var $parent = $(this).parents("tr");
                        $parent.addClass("td_line");
                        $parent.next(".hide").show();
                        $(this).addClass("cur").text("收起子订单");
                }
        });
        /*去预约*/
        $(".J_phoneCheapBook").click(function() {
                editWidget2('/manage/UserOrderPhoneCheapBook-' + $(this).attr("val") + '.html', 114, 392);
        });
        //摇便宜预约订金提示显示隐藏
        $(".phoneCheapTipSpan").hover(function() {
                $(this).next(".phoneCheapTip").show();
        }, function() {
                $(this).next(".phoneCheapTip").hide();
        });
        //摇便宜预约提示显示隐藏
        $(".J_phoneCheapBook_Tip").hover(function() {
                var pos = $(this).offset();
                $(this).parents("td").children(".phoneCheapBook_Tip").css({"left": pos.left - 103, "top": pos.top + 32}).show();
        }, function() {
                $(this).parents("td").children(".phoneCheapBook_Tip").hide();
        });
        /*取消订单弹出层*/
        $(".J_closeOrder").click(function() {
                editWidget2('/manage/UserOrderCancel-' + $(this).attr("val") + '.html', 254, 390);
        });
        /*更改订单弹出层*/
        $(".J_changeOrder").click(function() {
                editWidget2('/manage/UserOrderChange?orderCode=' + $(this).attr("val"), 367, 390);
        });
        /*更改上车地点弹出层*/
        $("#J-dress").click(function() {
                editWidget2("/manage/UserBoardingLocation-" + $(this).attr("val") + "-" + $(this).attr("productID") + ".html", 231, 472);
        });
        /*更改联系人信息弹出层*/
        $("#J-changeUser").click(function() {
                editWidget2("/manage/UserOrderUserInfo-" + $(this).attr("val") + ".html", 286, 462);
        });
        /*更改游客信息弹出层*/
        $(".J-changeManage").click(function() {
                var isChina = $(this).attr("isChina");
                if (isChina == 1) {
                        editWidget2("/manage/UserTouristDetail-1-" + $(this).attr("val") + ".html?type=order", 415, 502);
                } else {
                        editWidget2("/manage/UserTouristDetail-0-" + $(this).attr("val") + ".html?type=order", 558, 502);
                }
        });
        /*更改发票信息弹出层*/
        $("#J-invoice").click(function() {
                editWidget2("/manage/UserOrderInvoice-" + $(this).attr("val") + ".html", 335, 542);
        });
        /*时间查询*/
        $("#ddlMyOrder,#ddlTravelOrder,#ddlVisaOrder,#ddlTicketOrder").change(function() {
                location.href = "/manage/order-" + $(this).attr("actionType") + "-" + $("#ddlMyOrder").val() + "-" + $("#ddlTravelOrder").val() + "-" + $("#ddlVisaOrder").val() + "-" + $("#ddlTicketOrder").val() + "-1-1-1-1.html";
        });
        /*tips 提示*/
        $(".J_tipBox").hover(function() {
                $(this).find(".J_tip").show();
        }, function() {
                $(this).find(".J_tip").hide();
        });
        /*order tabs*/
        $(".J_orderListTab li").each(function(i) {
                var timer;
                $(this).click(function() {
                        $(this).addClass("cur").siblings().removeClass("cur");
                        $(".orderTabBox").hide();
                        $(".ListLoding").show();
                        clearTimeout(timer);
                        timer = null;
                        timer = setTimeout(function() {
                                $(".orderTabBox").hide();
                                $(".ListLoding").hide();
                                $(".orderTabBox").eq(i).show();
                        }, 500)
                });
        });
        /*tips 提示*/
        $(".J_tipBox").hover(function() {
                $(this).find(".J_tip").show();
        }, function() {
                $(this).find(".J_tip").hide();
        });

        //订单详情价格信息
        $(".J_priceMx").toggle(function() {
                $(".priceMx").show();
                $(this).removeClass("price_cur").text("收起价格明细");
        }, function() {
                $(".priceMx").hide();
                $(this).addClass("price_cur").text("查看价格明细")
        });

        //显示订单详情中订单处理跟踪的全部信息
        $(".J_showallodd").toggle(function() {
                $(".J_odd_detail dd:gt(2)").show();
                $(this).addClass("odd_detailless").text("收起");
        }, function() {
                $(".J_odd_detail dd:gt(2)").hide();
                $(this).removeClass("odd_detailless").text("显示全部")
        });
        //订单处理跟踪出游准备提示
        $(".odd_dobefore").hover(function() {
                $(".odd_doinfo").show();
        }, function() {
                $(".odd_doinfo").hide();
        });

        //订单列表页面订单跟踪
        $(".orderTable_gz").hover(function() {
                var taht = $(this);
                $.ajax({
                        url: "/manage/UserOrderProcess-" + taht.attr("val") + ".html",
                        type: "post",
                        dataType: "json",
                        data: {},
                        success: function(msg) {
                                $(".orderTable_gz").find(".order_gz_detail").html("").hide();
                                var str = "<dd class=\"j\"></dd><dt>详细信息</dt></dd>";
                                for (var i = 0; i < msg.length; i++) {
                                        str += "<dd><span class=\"t\">" + msg[i]["OperateDate"] + "</span><span class=\"i\">" + msg[i]["Remark"] + "</span></dd>";
                                }
                                taht.find(".order_gz_detail").html(str).show();
                                removeOrderProcessAHref();
                        },
                        error: function() {
                                taht.find(".order_gz_detail").html("<dd class=\"j\"></dd><dt>详细信息</dt><dd>系统繁忙，请稍候再试！</dd>");
                        }
                });
        }, function() {
                $(this).find(".order_gz_detail").hide();
        });
});

//绑定订单跟踪A标签链接。
function bindOrderProcessAHref() {
        $("#aDownloadContract,#aDownloadNotice,#aSafety").css("display", "none");
        $("#aOtherUser,#aGoPay,#aReviews").css("display", "none").attr("target", "_blank");
        var that = $(".wayPay a");
        $(that).each(function(i, item) {
                var atext = $(item).text();
                var ahref = $(item).attr("href");
                if (atext == "补充游客信息") {
                        $("#aOtherUser").attr("href", ahref).text(atext).css("display", "inline");
                } else if (atext == "修改游客信息") {
                        $("#aOtherUser").attr("href", ahref).text(atext).css("display", "inline");
                        $("#spOtherUser").css("display", "none");
                } else if (atext == "去支付") {
                        $("#aGoPay").attr("href", ahref).text(atext).css("display", "inline");
                } else if (atext == "合同") {
                        $("#aDownloadContract").attr("href", ahref).text("下载旅游" + atext).css("display", "inline");
                } else if (atext == "出团通知书") {
                        $("#aDownloadNotice").attr("href", ahref).text("下载" + atext).css("display", "inline");
                } else if (atext == "去点评") {
                        $("#aReviews").attr("href", ahref).text(atext).css("display", "inline");
                } else if (atext == "查看点评") {
                        $("#aReviews").attr("href", ahref).css("display", "none");
                }
        });

}
//隐藏订单跟踪A标签链接。
function removeOrderProcessAHref() {
        $("#aOtherUser,#aGoPay,#aDownloadContract,#aDownloadNotice,#aSafety,#aReviews").css("display", "none");
}